Choosing a camera and optimizing system parameters for speckle contrast optical spectroscopy

Speckle contrast optical spectroscopy (SCOS) is an emerging camera-based technique that can measure human cerebral blood flow (CBF) with high signal-to-noise ratio (SNR). At low photon flux levels typically encountered in human CBF measurements, camera noise and nonidealities could significantly impact SCOS measurement SNR and accuracy. Thus, a guide for characterizing, selecting, and optimizing a camera for SCOS measurements is crucial for the development of next-generation optical devices for monitoring human CBF and brain function. Here, we provide such a guide and illustrate it by evaluating three commercially available complementary metal–oxide–semiconductor cameras, considering a variety of factors including linearity, read noise, and quantization distortion. We show that some cameras that are well-suited for general intensity imaging could be challenged in accurately quantifying spatial contrast for SCOS. We then determine the optimal operating parameters for the preferred camera among the three and demonstrate measurement of human CBF with this selected low-cost camera. This work establishes a guideline for characterizing and selecting cameras as well as for determining optimal parameters for SCOS systems.


Characterization of camera dark offset and read noise variability
Twenty-five measurements of pixel-averaged dark offset I dark and read noise variance σ 2 r were performed at a rate of one measurement every 10 min, with the camera sensor covered to ensure no light was incident on the sensor.Between measurements, the camera continued to acquire images but did not save them.The camera was powered on but not acquiring images for 3 h prior to the first measurement, to allow for measuring the effect of camera warm-up on the read noise variability.The σ 2 r values were calculated using difference images in the same way as described in the previous section.The per-pixel I dark x, y and σ 2 r x, y were calculated from the pixel-wise temporal mean and variance across 1000 frames.

Model for quantization distortion and associated K 2 error
For the simulation of quantization distortion, we used 400 evenly spaced true mean values I true within the quantization interval between −0.5 DN and 0.5 DN, and 100 true variance values σ 2 true between 0 DN 2 and 1 DN 2 .We created a normal distribution for each possible combination of I true and σ 2 true values, with the assumption that the temporal distribution of read noise and shot noise can be approximated well with a normal distribution.We then quantized the values in each normal distribution and estimated the mean intensity I and variance σ 2 using the quantized values.We calculated the estimation error in the I and σ 2 for each combination of I true and σ 2 true values and found the maximum estimation error across all I true values at each σ 2 true value.To calculate the associated K 2 percentage error, we used the following expression based on the propagation of error formula for f = A/B, Figure 1.Characterization of camera gain and nonlinearity-induced K 2 error for three CMOS cameras.(a) Schematic of the setup for measuring the cameras' photon transfer curves.(b-d) Estimation of camera gain and linearity error (LE) for each camera's photon transfer curve.Here σ 2 is the variance of the intensity and I is the average intensity across all the pixels, in units of the camera's digital number (DN) output.Blue circles are the experimental data and red dashed lines are the linear regression lines.Error bars represent the temporal standard deviation of the variance of each difference image obtained.The linear regression is performed on data within a limited I range as indicated by the shaded region, where the shot noise is greater than twice the read noise and I is less than 70% of the camera's saturation capacity.The estimated camera gain is the slope of the regression line.The LE is calculated as the mean magnitude of the relative deviation of the measured variance from the regression line within the fitting range.(e-g) Estimation of the absolute nonlinearity-induced error in K 2 , | K 2 | , within the shaded region indicated in (b-d).Error bars represent the temporal standard deviation of the variance of each difference image divided by I 2 .HA: Hamamatsu Orca Fusion BT C15440-20UP; BAa: Basler a2A1920-160umPRO; BAd: Basler daA1280-54um. Vol:.(1234567890)

Scientific Reports
| (2024) 14:11915 | https://doi.org/10.1038/s41598-024-62106-ywww.nature.com/scientificreports/where �(. . . ) is the deviation of the estimated value from the true value.For a conservative estimate of the K 2 error, we assumed that σ 2 and I 2 were independent, meaning that Cov σ 2 , �I� 2 = 0 .We found the maximum K 2 error across all I true values at each σ 2 true value.Note that using a quantization interval farther away from zero will result in a slightly lower K 2 error at a given σ 2 true value, due to a decrease in the �( I 2 ) I 2 term in the above formula.

Noise correction procedure for SCOS measurements
The aim of noise correction for SCOS is to correct for the biases in the speckle contrast contributed by shot noise, read noise, quantization noise, and spatial nonuniformity in illumination.Shot noise arises from the random variation in the number of incident photons on each pixel.Read noise is the aggregate random variation in the camera's intensity reading arising from the processes of converting photoelectrons to a voltage, amplifying the voltage, and digitizing the voltage.The act of estimating the variance in intensity from quantized intensity values such as the camera's digital output introduces an additional bias of 1/12 in the measured variance according to quantization theory 31,32 .The added spatial variance from spatially nonuniform illumination on the sensor must also be subtracted.We recently developed an experimentally validated noise correction procedure 26 for SCOS which corrects for the above noise sources and is summarized below.
We first subtract the mean dark image from the raw speckle images.We then select the region of interest (ROI) in the speckle image for the speckle contrast calculation, typically chosen to match the fiber output image.We calculate the raw speckle contrast squared K 2 raw = (σ (I)/�I�) 2 for each 7 × 7 pixel window within the ROI, where the intensity I is measured in digital numbers (DN) for all pixels.We use linear fitting to reduce the noise in each window's mean intensity time course, as described previously 26 and summarized below.We first obtain the average intensity time course I all (t) across the ROI.We assume that the average intensity time course for each window, I w (t) , is linearly related to I all (t) and given by I w (t) = a • I all (t) + b .The coefficients a and b are obtained from the fitting.The resulting fit, �I(t)� = a • I all (t) + b , is used in the denominator of K raw for each window.After obtaining the raw contrast squared K 2 raw , we subtract the speckle contrast bias terms arising from shot noise K 2 s , read noise K 2 r , spatial nonuniformity in illumination K 2 sp , and quantization bias K 2 q as follows, where g is the camera gain, σ r is the read noise of the camera, and σ 2 sp is the spatial variance obtained from a temporal average of the speckle images.For K 2 q , the quantization-induced bias in variance is assumed to be 1/12 31,32 .We then obtain an intensity-weighted average of K 2 f , the "fundamental" blood-flow-induced contrast squared, across all the 7 × 7 windows within the ROI to obtain a single K 2 f value for each camera frame.

Analytical noise model for SCOS
The noise model for SCOS has been developed and experimentally validated previously 25 and is summarized here.The noise in SCOS measurements σ (K 2 raw ) is the root-sum-square of the individual contributions from fundamental noise, shot noise, and read noise: where NIO is the number of independent observations, N fr is the number of frames averaged, c K s and c K r are calibration factors set to 1.90 and 1.47 respectively assuming an exponential intensity distribution for the speckle pattern, and w 2 is the number of pixels imaging the fiber output which has an upper limit equal to the number of pixels on the camera.NIO is given by NIO = w 2 f s/p , where f s/p is a factor that accounts for the degree of spatial correlation across pixels as described in more detail here 25 .The SNR is then given by

Study participants
One participant within the 20 to 60 year age group with no prior diagnosis or treatment of neurological disorders was recruited for this study.Sex, gender, race, and ethnicity were not considered during recruitment.The participant was recruited through word of mouth on the Boston University campus.The experimental procedure and protocols were approved and carried out in accordance with the regulations of Institutional Review Board of Boston University.All experiments were performed in accordance with relevant guidelines and regulations,

Description of SCOS system hardware used for human CBF measurement
The SCOS system broadly consists of the laser source and the detection setup.Within the laser source, continuous-wave laser light is emitted by an 852 nm laser diode (Thorlabs LD852-SEV600) which is housed in a temperature-controlled laser mount (Thorlabs LDM90) and driven by a combined current and temperature controller (Thorlabs ITC4001).The laser emission from the diode is collimated by an aspheric lens (Thorlabs C110TMD-B) that is attached to the laser mount via an adapter plate (Thorlabs LDMXY).The collimated beam is sent through an optical isolator (Thorlabs IO-5-850-VLP) to protect the diode from back-reflected light.The free-space beam is then blocked periodically by a 10% duty-cycle optical chopper (Thorlabs MC2000B with MC1F2P10 chopper blade) to convert the continuous-wave beam to a pulsed beam.The pulsed beam is then coupled to an optical fiber using a fiber coupler (Thorlabs PAF-X-15-PC-B FiberPort), and the beam is emitted into the subject's skin by applying the distal end of the optical fiber to the subject's forehead.
In the detection setup, a custom fiber bundle (~ 3700 strands of 37-µm core diameter multimode fiber, 0.66 NA) collects backscattered light from the subject and transmits it to the camera.The camera end of the fiber bundle is rectangularly shaped (3 × 1.64 mm) to approximately match the aspect ratio of the camera sensor.The fiber bundle image is magnified by a 4-f lens system consisting of an aspheric condenser lens (Thorlabs ACL25416U-B) and a plano-convex lens (Thorlabs LA1027-B).The Basler a2A1920-160umPRO CMOS camera is placed around the focal point of the plano-convex lens.We slightly alter the distance between the fiber bundle and the aspheric condenser lens from the focal length to defocus the fiber bundle image and reduce spatial heterogeneity.
The average illumination power of our system was 38 mW.We calculated the average photon flux per speckle of our system during our human CBF measurement (shown later) as follows.The photon flux per speckle is derived from the mean intensity I in units of DN from the camera, the camera gain g , the camera's quantum efficiency (QE) at the laser's wavelength of 852 nm, the exposure time T exp , and the speckle-to-pixel size ratio (s/p) as follows: For our human CBF measurement using the above system �I� = 25 DN, g = 0.58954 DN/e -as measured from the fit to the photon transfer curve, QE(852 nm) = 0.16 as given in the camera specifications, T exp = 0.833 ms, and (s/p) 2 = 0.7112 as measured using a static phantom.This leads to an instantaneous photon flux per speckle of 2.2619 × 10 5 s -1 .As mentioned earlier, we use a 10% duty cycle optical chopper in our system.Therefore, the average photon flux per speckle is a tenth of the instantaneous value above, or 22,619 s -1 .We use this value in our analytical SCOS noise model later in this work.

fNIRS and SCOS data acquisition
We used a commercial high-density fNIRS system to locate the activation region on the forehead with the largest task-averaged change in total hemoglobin concentration in response to the mental subtraction task (described in the next section).The commercial fNIRS system (NIRSport2, NIRx) consists of 14 sources and 32 detectors which are placed on the prefrontal cortex region.The source and detector optodes are mounted on a NinjaCap, an in-house 3D printed cap made of a flexible material (NinjaFlex, NinjaTek) that allows for customizable highdensity fNIRS measurements with commercial fNIRS systems.The first and second nearest source-detector separation distances are 19 mm and 33 mm respectively.The cap is positioned on the head using anatomical landmarks (nasion, inion, and left/right pre-auricular points), such that the EEG 10-10 midline central electrode site (Cz) is matched between the cap and the head.The signal quality for each source-detector pair was tested through the Aurora fNIRS acquisition software (NIRx) prior to the fNIRS measurement.
For the SCOS measurement, we used the same NinjaCap in order to match the source-detector locations used in the fNIRS measurement.The camera was connected to a computer via a USB 3.0 cable for both power and data acquisition.The camera's external trigger was used to synchronize both the chopper wheel controller (Thorlabs MC2000B) and the data acquisition card (NI USB-6002).We adjusted the phase of the chopper wheel manually so that the incident laser pulse was contained within the camera's exposure window.
The data acquisition card also received the trigger signal from a stimulus tracker (Cedrus StimTracker Quad) which indicated the timing of the stimuli to the subject.The stimulus tracker recorded the change in brightness at a corner of the computer display which occurred simultaneously with presentation of stimulus to the subject.
The data acquisition card was connected via micro-USB to the computer and controlled using MATLAB software.The trigger signals from the camera and stimulus tracker were recorded to the computer through the data acquisition card and used later for stimulus-based trial averaging.

Mental subtraction task protocol
During the mental subtraction task, the participant was seated in front of a computer monitor that provided visual cues.The participant was presented with a cross symbol (+) in the center of the screen during an initial baseline measurement and in between mental subtraction trials.During a mental subtraction trial, the participant was visually presented with a subtraction problem comprising a random three-digit minuend (e.g.370) and one of three subtrahends (6, 7, or 13).The participant repeatedly subtracted the subtrahend (e.g.13) from the difference (e.g.357, 344, 331) until the problem was replaced by the cross symbol on the screen, upon which the participant rested until the next trial.Each problem was displayed for 20 s and the interval between problems was randomly varied between 20 and 25 s.Each "run" of the mental subtraction task consisted of five trials.Each participant performed a total of 3 runs (15 trials in total) which lasted 12 min.No feedback regarding the measurement was given to the participant during and after the measurement.

Statistical information
A two-sample, two-tailed t-test was used to determine whether the changes in optical density (OD) and blood flow index (BFi) measured during 15 trials of the mental subtraction task were statistically significant.For both ΔOD and ΔBFi, 15 values-one from each trial-were used at the beginning of the trial (time = 0 s) and 15 values were used at the maximum trial-averaged value (time ≈ 13.5 s for ΔOD and time ≈ 10.5 s for ΔBFi).ΔOD: p = 2.04 × 10 -7 , t = 6.83, df = 28.ΔBFi: p = 1.06 × 10 -5 , t = 5.35, df = 28.

Results
In SCOS, the speckle contrast K = σ (I)/�I� is calculated, where I is the speckle intensity measured by the camera in units of the camera's digital output or digital numbers (DN), σ (. . . ) denotes the standard deviation, and . . .denotes the average over pixels.A noise correction procedure has been developed 26 to remove the biases in σ (I) and I , which requires accurate measurements of camera gain g , pixel-wise mean dark offset I dark , and pixel- wise read noise σ r .Camera nonidealities can introduce errors in the estimated values of g , I dark , and σ r Fig. 2. Thus, it is important to characterize and assess the impact of the nonidealities when choosing a camera for SCOS.
Our camera selection and system optimization procedure for SCOS is summarized as follows: Camera selection: Step 1. Measure the camera's photon transfer curve, defined as the variance of the intensity σ 2 (I) versus the average intensity I (See Methods section for details): a. Estimate the camera's gain g from the slope of the linear fit to the photon transfer curve b.Evaluate the camera nonlinearity in the photon transfer curve and calculate its impact on SCOS measurements Step 2. Measure the camera's mean dark offset I dark and read noise σ r distributions across pixels (See Methods section for details): a. Determine whether there is quantization distortion that could prevent accurate measurement of the camera's I dark and σ r values in units of DN b.Using the measured camera gain g from Step 1, convert from units of DN to electrons (e -) in order to compare the σ r distributions between different cameras Step 3. Downselect cameras based on their properties including photon transfer curve linearity, read noise level, camera gain value, quantization distortion, and cost.Camera and system parameter optimization: Step 4. Using the camera parameters obtained from characterization, find the optimal camera exposure time T exp and speckle-to-pixel size ratio s/p for maximal SNR using the SCOS noise model 25 : a.If the laser source can be pulsed, optimize the laser's peak power and duty cycle in conjunction with the T exp and s/p for maximal SCOS SNR

Camera selection
The basic camera characterization process for SCOS consists of measuring the camera gain g , pixel-wise dark offset I dark , and pixel-wise read noise σ r .The purpose of this process, apart from acquiring the parameters needed for SCOS noise correction, is to detect any presence of camera nonidealities that are not corrected for by our current SCOS noise correction procedure 26 due to their complicated dependence on intensity or temporal fluctuation.These nonidealities include the intensity dependence in g and the distortion in the measured I dark and σ r due to insufficiently high g , and they impact SCOS measurement accuracy We illustrate this process for the three commercially available CMOS cameras mentioned in the Introduction (HA, BAa, BAd).
Step 1: Measure the camera's photon transfer curve The schematic of the camera characterization setup is shown in Fig. 1a.In Fig. 1b-d, we show the photon transfer curve for each camera, measured using uniform incoherent illumination with mean intensities I spanning the full bit depth of each camera.The slope of the linear fit to the photon transfer curve is the camera gain value g which is needed to correct for the bias in K introduced by shot noise in SCOS measurements.A camera's gain may be adjustable and is generally influenced by other camera settings such as bit depth.Therefore, the gain value reported in a camera datasheet may not be applicable to the user's specific camera settings and we recommend that the user obtain g from their own photon transfer curve measurement.We see in Fig. 1b that the photon transfer curve for the more costly scientific CMOS camera, HA, exhibits sharp deviations from the linear fit while the lower-cost CMOS cameras, BAa (Fig. 1c) and BAd (Fig. 1d), are more linear.The linearity is quantified by the linearity error, calculated as the mean magnitude of the relative deviation from the linear fit � y − y / y � , where y is the experimentally obtained data and y is the fitting result.All three cameras deviate from linear behavior at high DN values near saturation, and thus that region should be avoided when conducting SCOS measurements.For human brain measurements, the photon flux is usually low enough to avoid the saturation region of the cameras.
Systematic nonlinearity in the camera's photon transfer curve can induce errors in the measured speckle contrast K .This occurs because such nonlinearities produce deviations from the anticipated bias in K induced by shot noise.In Fig. 1e-g, we show the error in K 2 induced by this systematic nonlinearity for all three cameras as a function of I .We estimate the magnitude of the systematic error in K 2 due to the systematic nonlinearities as �K 2 = σ 2 (I) − σ 2 fit (I) /�I� 2 , where σ 2 fit (I) is the variance of the intensity predicted from the linear fit to the photon transfer curve.Because K 2 is inversely related to I 2 , deviations in σ 2 (I) from the linear fit have larger impacts on K 2 at lower I values which are more relevant to human brain measurements.Thus, we scale the relative error in σ 2 (I) by 1/ I to increase the weighting at lower I values and minimize the squared sum of the scaled relative errors when deriving the linear fit to the photon transfer curve.
Given the intensity-dependence of the camera gain value g , which manifests as nonlinearity in the photon transfer curve (Fig. 1b-d), the fitting of the photon transfer curve to estimate g should be performed within the user's operating intensity range to maximize the accuracy of the SCOS noise correction (shaded region in Fig. 1b-d).In this work, we chose a lower operating limit corresponding to the I at which shot noise is equal to twice the camera's read noise, to favor operating in the shot-noise-limited regime.We chose an upper operating limit corresponding to 70% of the camera's saturation intensity, I sat , defined as the I at which the intensity histogram from an image with temporal noise included starts to become clipped at the camera's maximum intensity value.I sat corresponds to the beginning of the plateau in the first-order response, defined as the mean intensity I versus the illumination power .. We chose this upper operating limit to avoid the roll-off of the photon transfer curve near saturation.
We see that the nonlinearity-induced K 2 within the chosen operating intensity range can be as high as 2 × 10 -3 for the HA and 7 × 10 -4 for the BAa, which are 10% and 3.5% respectively of the average K 2 f value (~ 2 × 10 -2 ) from our human CBF measurement (shown later).In addition, the abrupt nonlinearities in the HA's photon transfer curve cause sharp peaks in K 2 between certain I values.The BAd shows a comparatively low maximum K 2 of 1.5 × 10 -5 within the chosen operating intensity range, but it should be noted that a much longer integration time would be required to reach its lower operating limit in a human CBF measurement due to its high read noise (shown later).
Two options are available for reducing the impact of the nonlinearity-induced K 2 on SCOS measurement accuracy.The first is to ensure that K 2 is negligible compared to the measured "fundamental" blood-flow- induced contrast squared, K 2 f , within the I range used in the measurement.Since K 2 is roughly inversely related to T 2 exp through I 2 while K 2 f is inversely related to T exp , K 2 can be decreased relative to K 2 f by increasing T exp .Another option is to correct for the nonlinearity-induced K 2 , which in principle can be done if g is characterized precisely over the operating intensity range.Correction of the nonlinearity-induced K 2 however is complicated by the fact that the speckle pattern and the illumination pattern contain a distribution of I values in contrast to the uniform incoherent (LED) illumination used to characterize a camera.
Step 2: Measure the camera's mean dark offset I dark and read noise σ r distributions across pixels The per-pixel mean dark offset I dark x, y and read noise variance σ 2 r x, y for a camera are obtained by cal- culating the temporal mean and variance, respectively, for every pixel across a set of dark images.In the SCOS noise correction procedure, the I dark x, y image is subtracted from every raw image to correct for the camera's dark offset nonuniformity, while the σ 2 r x, y image is used to calculate the read-noise-induced contrast term, K 2 r = σ 2 r /�I� 2 .Shown in Fig. 2a, b are the I dark and σ 2 r distributions across pixels, respectively, for the three cameras in units of DN.To compare read noise distributions between cameras, the read noise values in units of DN need to be converted to units of electrons (e − ) by dividing the DN values by the previously characterized camera gain g (DN/e -). Figure 2c shows the σ 2 r distributions for the three cameras in units of e -2 .We see that the HA and BAa have similar root-mean-square (RMS) read noise values (HA: 1.28 e -, BAa: 1.97 e -), despite the HA costing considerably more (~ $26,000 vs. ~ $500 at the time of publication).The BAd has much higher (> 5x) RMS read noise (10.33 e -) than the other two cameras.Besides lowering SNR, the higher read noise would require us to use a much longer (> 25x) camera integration time with the BAd to achieve the same shot-noise-limited SCOS SNR during human CBF measurements at long source-detector separation, limiting the acquisition rate as compared to what is achievable with other cameras.
Note that while an RMS read noise value is typically reported in a camera's datasheet, a camera's read noise is generally influenced by other camera settings such as analog gain and bit depth.In addition, since a CMOS camera uses an independent amplifier for each pixel, there is read noise variation across pixels that needs to be quantified for our SCOS noise correction procedure.For these reasons, the user should perform a per-pixel read noise (and dark offset) measurement with the camera settings that they would like to use for SCOS.Obtaining the read noise for all pixels also enables the identification of outlier pixels with highly elevated read noise.The user can choose to exclude these pixels from analysis in the SCOS noise correction procedure.
Although the BAd has the largest mean read noise variance σ 2 r in units of e -2 , the σ 2 r distribution for BAd in Fig. 2b is almost entirely below 1 DN 2 and has a mean of 0.23 DN 2 , with many pixels showing near-zero σ 2 r .(The BAa and HA cameras have mean σ 2 r values of 1.3 DN 2 and 35.9 DN 2 respectively.)Because of the BAd's low camera gain value (Fig. 1d), its measured per-pixel dark offset I dark x, y and read noise σ r x, y values are distorted by quantization from the true I dark x, y and σ r x, y values, respectively.
Quantization occurs when a pixel's analog voltage reading is converted to a digital integer value, and it is another source of noise that affects SCOS measurements.For instance, assuming that a rounding operation is implemented in the camera, an intensity reading corresponding to an unquantized value of 4.1 will be rounded to 4, generating an error of 0.1.In principle, observing multiple realizations of the quantized signal will allow for recovering the unquantized mean intensity and the variance, provided that there is sufficiently large variance in the observations.Quantization distortion refers to the error in the recovered mean and variance, which becomes non-negligible when the signal variance in units of camera digital numbers (DN 2 ) becomes small relative to 1 DN.To explore the effect of quantization distortion, we numerically drew numbers from Gaussian distributions with certain mean and variance values, and then estimated the mean and variance from the quantized numbers (See Methods).
Figure 3a, b show the maximum quantization-distortion-induced error in the estimated mean intensity I and variance σ 2 , respectively, as a function of the true variance σ 2 true of the simulated Gaussian distributions.They show that below a variance of 0.2 DN 2 , which applies to a significant fraction of the pixels in the BAd's dark images, the maximum quantization-induced errors in both the estimated I and σ 2 are no longer negligible.This causes the subtraction of the I dark pattern and the read-noise-induced contrast term K 2 r to be inaccurate in SCOS measurements with the BAd, namely due to its low camera gain value.The impact of the quantization distortion on SCOS measurements is expressed in Fig. 3c as the maximum percent error in K 2 as a function of σ 2 true .We see that above σ 2 true = 0.4 DN 2 , the quantization-induced error in K 2 is negligible after subtracting the quantization-induced bias of 1/12 31,32 from the measured σ 2 .Subtraction of the quantization variance bias is done in the SCOS noise correction procedure as described in the Methods.We recommend using a camera with a high enough gain value such that the camera's σ 2 r distribution is entirely above 0.4 DN 2 where quantization distortion becomes negligible.We note that some cameras like the BAd only allow for increasing the postquantization or "digital" gain which multiplies the DN values by a factor d g .This does not mitigate quantization distortion because it simply multiplies the measured mean and variance by d g and d 2 g while effectively increasing the quantization interval size in DN by the same factor d g .With the results from this camera characterization process, we decided that the BAd (~ $200 at the time of purchase) is not a preferred camera for SCOS among the three because it suffers from quantization-distortioninduced K 2 error and has significantly higher (> 5x) RMS read noise than the other two cameras, which would limit acquisition rate and SNR in SCOS.The HA is considerably more expensive (~ $26,000 at the time of purchase) than the other two cameras and has the highest nonlinearity within the chosen operating limits for the cameras, which results in the HA suffering from relatively large peaks in nonlinearity-induced systematic K 2 error.While during a measurement with the HA one could in principle avoid the intensity ranges where the peaks in systematic K 2 error are located, in practice that may be difficult due to intra-and inter-subject variabil- ity and the existence of an intensity distribution in the illumination and speckle patterns.Hence, the HA is not a preferred option either for SCOS.Since the BAa (~ $500 at the time of purchase) has negligible quantization distortion, comparable read noise level to the HA, and lower peaks in nonlinearity-induced K 2 error than the HA within the chosen operating range, we considered it the best camera choice among the original three for SCOS.

Camera and system parameter optimization
Once cameras under consideration are characterized and those with negligible nonlinearity and quantization distortion are identified, the next step is to optimize the SCOS system operating parameters for maximal SNR.
The parameters having the largest influence on SCOS measurement SNR are the exposure time T exp and speckle- to-pixel size ratio s/p.Since we have previously identified the BAa as our preferred camera in the camera selection process, we will use it to illustrate the concepts in the system parameter optimization process.
In practice, we adjust T exp and s/p to minimize read noise contributions to the measured speckle con- trast.More specifically, we desire to make measurements in the shot-noise-limited regime in which the readnoise-induced contrast squared K 2 r = σ 2 r /�I� 2 is much smaller than the shot-noise-induced contrast squared K 2 s = g/�I� .A challenge of operating in a regime where the contribution of read noise is non-negligible is that the read noise can vary in time, as we illustrate in Fig. 4. Recall that in Fig. 2 we showed examples of per-pixel mean dark offset I dark x, y and read noise variance σ 2 r x, y measured from ~ 10 s of data acquisition.To explore the stability of the I dark and σ 2 r distributions over a longer timescale (> 10 min), we measured the pixel-averaged I dark and σ 2 r values from the BAa camera every 10 min for 4 h as shown in Fig. 4a.The camera was powered on but not acquiring images for 3 h prior to the first measurement, while in between measurements the camera continued to acquire images but did not save them.We see that I dark and σ 2 r varied over time, possibly due to environmental factors such as fluctuations in the camera's temperature (we observed this behavior for all three cameras).This effect was more pronounced immediately after the camera started acquiring images from the first measurement, presumably because the process of acquiring images caused the camera's temperature to increase until reaching a new steady state.This effect can impact the accuracy of noise correction in the low-photon-flux regime where the contribution of read noise is non-negligible.Figure 4b, c show the variations in the per-pixel I dark and σ 2 r respectively.To reduce the impact of inaccuracy in the calculated read-noise-induced speckle contrast K r due to the camera's read noise variability, we recommend avoiding operating regimes where K 2 r is dominant.We also recommend the practice of updating the recorded per-pixel I dark x, y and σ 2 r x, y before each SCOS measurement for more accurate noise correction.The results in Fig. 4a suggest that having the camera "warm up" by acquiring images for some time prior to conducting a SCOS measurement may reduce the read noise variation during the measurement.Step 4: Using the camera parameters obtained from characterization, find the optimal camera exposure time and s/p for maximal SNR Having established that the user should try to operate in the shot-noise-limited regime, we now discuss how to accomplish that and maximize SCOS SNR by choosing T exp and s/p.We define SNR in SCOS as SNR = K 2 f /σ K 2 raw , where σ K 2 raw is the root-sum-square of the noise from individual K 2 terms.We use our recently developed and validated SCOS noise model 25 as described in the Methods to predict the SNR as functions of T exp and s/p in Fig. 5, assuming a photon flux per speckle of 22,619 s -1 as obtained on average during our human CBF measurement (shown later) and a measurement interval time of 100 ms over which the measured K 2 f values from individual camera frames are averaged.In addition to the RMS read noise characterized previously, the noise model uses the following camera parameters: quantum efficiency (QE) at the operating wavelength, maximum frame rate ( f max ), and total number of pixels.Those camera parameters are readily obtained from the camera's datasheet.For reference, the BAa camera has a QE of 16% at 852 nm wavelength, f max of 120 Hz at 10-bit depth, and 1936 × 1216 pixels.
We see in Fig. 5a that, for a given s/p determined by the optical setup and the camera's pixel size, SNR = K 2 f /σ K 2 raw plateaus at a particular T exp which indicates the beginning of the shot-noise-limited regime where shot-noise-induced contrast K s dominates and the impact of camera read noise becomes negligible.The plateau- ing in SNR occurs because both K 2 f and noise in the measured K 2 s , i.e. σ K 2 s which is the dominant term in σ K 2 raw under the shot-noise-limited regime, are inversely proportional to T exp .The reduction in SNR for T exp > 8.3 ms is due to a decrease in the camera's frame rate and consequent reduction in frame averaging within the 100 ms measurement interval time.This happens because T exp becomes larger than 1/ f max .For the SNR's depend- ence on s/p value (Fig. 5b), we show the cases where SNR is limited by the number of speckles assuming an unlimited number of pixels (speckle-count-limited), and where it is limited by the number of pixels assuming an unlimited number of speckles (pixel-count-limited).We see that for the speckle-count-limited case, there exists an optimal s/p ratio that maximizes SNR for a given T exp and photon flux per speckle of 22,619 s -1 .Experimentally, this case corresponds to a fiber-based SCOS system where the number of fiber modes is fixed.If there are not enough pixels on the camera to capture all the speckles/modes, we need to consider the pixel-count-limited case.We see that in such a case, a small s/p is preferred to maximize SNR, as more speckles are imaged on the same camera.For a fiber-based SCOS system utilizing a camera with a finite number of pixels and a rectangular fiber bundle whose aspect ratio matches that of the camera sensor, the SNR dependence on s/p follows the lower of the two SNR curves (solid red and blue lines) at any given s/p value in Fig. 5b.When the fiber output image is totally contained within the camera's pixel array, this corresponds to the speckle-count-limited case.When the fiber output image is enlarged beyond the bounds of the pixel array, this corresponds to the pixel-count-limited case.
The intersection point of the two curves, where the fiber's output is matched to the size of the camera's pixel array, optimally balances the s/p and the number of speckles sampled and gives the maximum SNR in our system with the BAa camera.For cameras with higher read noise, the maximum SNR might be achieved when s/p is reduced such that the fiber's output does not fill the entire pixel array (See supplementary Fig. S2).This is because reducing the s/p increases the photon flux per pixel and helps the system achieve shot-noise-limited performance.In practice, the user should determine the optimal s/p for their experimental setup by obtaining the required input parameters to the SCOS noise model 25 (photon flux per speckle, camera parameters, etc.) and running the model as illustrated in Fig. 5. 3 ms for speckle-count-limited and pixel-count-limited cases.When the SCOS system is speckle-count-limited, the total number of speckles/fiber modes is fixed at M = 3.3 × 10 6 , estimated from the area of the fiber output image and the s/p ratio obtained experimentally.In the specklecount-limited case we assume that the camera has enough pixels to image all the speckles.When the system is pixel-count-limited, the total number of pixels is fixed at 1936 × 1216 pixels for the BAa camera, and we assume all pixels are filled with speckles.The SNR vs. s/p of our fiber-based SCOS system follows the solid red and blue lines.BAa camera parameter values of 1.97 e − RMS read noise, 16% quantum efficiency (QE) at 852 nm wavelength, 120 Hz maximum frame rate ( f max ) at 10-bit depth, and 1936 × 1216 pixels were used.An average photon flux per speckle of 22,619 s -1 (as derived in the Methods) and a measurement rate of 10 Hz were used.We have discussed that operating in the shot-noise-limited regime is recommended for more accurate and higher-SNR SCOS measurements.In Fig. 5, we illustrated how to achieve shot-noise-limited performance by adjusting T exp and s/p.Another way to achieve shot-noise-limited performance and further improve SNR is to increase the peak optical power within the camera exposure time while keeping the average power within the safety limit for human measurements 26 .To describe this, we introduce another parameter which is the laser pulsing factor (PF), defined as the inverse of the duty cycle of a pulsed laser source.The laser's peak power can be increased by the PF while maintaining the same average power, with the peak and average power within the safety limit.We show in Fig. 6 examples of the SNR calculated as functions of s/p and T exp for PF = 1 and PF = 10 for both the speckle-count-limited case (Fig. 6a, b) and the pixel-count-limited case (Fig. 6d, e).We see that increasing the PF generally increases the SNR by the same factor (except in the fundamental-noise-limited regime), namely through the reduction in T exp by the PF which increases K 2 f ∝ 1/T exp by the same factor while maintaining K 2 s ∝ 1/ c p T exp and K 2 r ∝ 1/ c p T exp 2 at the same value, where c p is the photon flux per pixel.
Note that at a higher PF, since the duty cycle is reduced, the acquisition rate could be impacted when PF • T exp becomes larger than 1/ f max .Figure 6c, f show that the optimal SNR, i.e. the maximum SNR achieved for the BAa camera at a given PF across all s/p and T exp values tested, increases linearly with PF until it plateaus in the fundamental-noise-limited regime, where K 2 f dominates all other speckle contrast components.In practice, PF is limited by the availability of high-peak-power pulsed laser sources and laser safety limits.In both the speckle-count-limited and pixel-countlimited cases, the optimal way of increasing the PF while maintaining the same average power is by decreasing T exp while maintaining the same frame rate.We see in the speckle-count-limited case in Fig. 6c that, near the fundamental-noise-limited regime, K 2 s and K 2 r increase because the optimal s/p has changed.In contrast, for the pixel-count-limited case, SNR is maximized by keeping the s/p at the minimum achievable value (s/p = 0.01 in this simulation) to maximize the number of speckles sampled.
Since blood-flow-induced speckle contrast K f decreases linearly with decreasing s/p at s/p ≪ 1, one may wonder if the spatial contrast would become too small to resolve from the camera's quantized output at very low s/p.However, since �I� 2 ∝ 1/ s/p 4 and K 2 f ∝ s/p 2 for s/p ≪ 1 , the fundamental signal's variance σ 2 f increases with decreasing s/p as σ 2 f (I) ∝ 1/ s/p 2 and quantization distortion does not become a problem.The only limit to decreasing s/p would be the camera's saturation limit and the total number of speckles available.Finally, in Fig. 7, we demonstrate experimentally the measurement of human CBF and brain activation at 33 mm source-detector separation using optimal parameter values (s/p = 0.84 and T exp = 0.83 ms) for our system comprising the low-cost BAa camera and an 852 nm wavelength pulsed laser operating at PF = 10 as described in the Methods.Figure 7a shows the SCOS measurement setup which is described in detail in the Methods.We see in Fig. 7b, c the cardiac pulsatile signal in mean intensity I and BFi = 1/K 2 f , respectively, as measured using our SCOS system.No frame averaging was performed.The magnitude of the nonlinearity-induced K 2 error for the BAa camera (Fig. 1f) within the I range of the measurement (25-28 DN) is less than 4 × 10 -4 , or less than 2% of the average K 2 f (2.4 × 10 -2 ) of the measurement.Morphological features of the cardiac signal including the three peaks (P1, P2, P3) and dicrotic notch are clearly visible in the BFi signal (Fig. 7c) while absent from the intensity signal (Fig. 7b).In Fig. 7d, e, we show measurement of brain activation in response to a mental subtraction task described in the Methods.To this end, we first used a commercial high-density fNIRS system to locate the activation region on the forehead with the largest task-averaged change in total hemoglobin concentration.We then placed our fiber-based SCOS source and detector optodes in the same region to measure changes in both optical density (OD) and BFi.We see that both ΔOD = log 10 (I 0 /I(t)) (Fig. 7d) and ΔBFi (Fig. 7e) show significant (ΔOD: p = 2.04 × 10 -7 ; ΔBFi: p = 1.06 × 10 -5 , two-tailed t-test) increases during brain activation and relaxation to baseline after activation.

Discussion
We have shown how CMOS camera noise and nonidealities can significantly impact SCOS measurement SNR and accuracy in the low-photon-flux regime relevant to human brain measurements.As the information on specific camera characteristics needed to accurately correct for noise and to determine a camera's suitability for SCOS is not available from published camera specifications, there is a need for a guide such as the one presented in this work to allow SCOS system developers to characterize, select, and optimize cameras on their own.By illustrating our guide using three cameras from different price ranges and showing that higher-end cameras designed for general imaging applications are not necessarily more suitable for SCOS than lower-end cameras, we have underscored the importance of approaching camera selection for SCOS based on the evaluation of specific camera attributes that are relevant to SCOS.Following our procedure to optimize the SCOS system, we achieved with the relatively inexpensive BAa CMOS camera (~ $500 at the time of purchase) comparable cardiac pulsatile waveform quality and recovery of brain activation (Fig. 7) to that of our previous human measurement with the HA scientific CMOS camera (~ $26,000 at the time of purchase) 26 .Note that when we were using the HA camera, we had to lower the laser power for subjects on multiple occasions, only to ensure that the system was operating in a more linear region of the photon transfer curve where the nonlinearity-induced K 2 error was negligible compared to the average K 2 f at the time (~ 3 × 10 -3 ).This reduced the photon flux and hence the SNR.Regarding camera nonlinearity, which is the first nonideality examined in our procedure, we note that published camera specifications typically provide a linearity metric only for the first-order response, defined as the mean intensity I versus the illumination power .While good first-order linearity alone might be enough for imaging applications that are primarily concerned with capturing intensity information, SCOS requires good linearity in the second-order response as well, defined as the variance of intensity σ 2 (I) versus the illumination power (See Supplemental Fig. S1).Hence in our procedure we assess the linearity of the camera's photon transfer curve ( σ 2 (I) vs.I ) which contains information about both the first-order and second-order responses.Since camera manufacturers do not typically publish photon transfer curves with sufficient resolution in lower camera counts, the user should follow the procedure presented in this work to evaluate the linearity of the photon transfer curve on their own, with particular attention paid to the intensity range that the user expects to utilize in actual SCOS measurements.
While we have corrected for the camera's spatial nonuniformity in dark offset (also known as dark signal nonuniformity or DSNU) by subtracting the dark offset image from every raw image taken in a measurement, we do not explicitly correct for the impact of spatial nonuniformity in gain (also known as photoresponse nonuniformity or PRNU) on the estimation of the shot-noise-induced speckle contrast.Both types of nonuniformity arise from the implementation of individual amplifiers per pixel in CMOS cameras.In our procedure, we measure the photon transfer curve and estimate the average camera gain across all pixels.If the user intends to use sub-regions of the pixel array, we suggest measuring the photon transfer curve and estimating the gain within those sub-regions if significant nonuniformity in gain is suspected (we saw evidence of this in the HA camera).Note that measuring the photon transfer curve from less pixels may mean that more images would be needed to adequately suppress the noise in the mean intensity I and variance of intensity σ 2 (I) in the photon transfer curve.Another major camera parameter that a user is likely to consider when choosing between cameras is maximum frame rate.The required frame rate is largely dictated by the user's application.For instance, a frame rate of at least 100 fps is preferred to sufficiently sample the pulsatile blood flow waveform for the extraction of hemodynamic parameters such as pulsatility index, critical closing pressure, and cerebrovascular resistance 33 .To achieve the above acquisition rate, DCS requires cardiac-gated averaging of as many as 50 arterial pulses to overcome the relatively low SNR, which distorts the pulsatile waveform and slows the measurement rate of hemodynamic parameters 33 .With SCOS, a user can potentially perform pulsatile waveform analysis with little to no cardiac-gated averaging, allowing for estimation of hemodynamic parameters at the cardiac frequency.We note that increasing the camera frame rate beyond the rate associated with the speckle decorrelation time-typically on the order of 10 μs for human CBF measurements-would not provide any SNR benefit from frame averaging because the speckle observations no longer become independent.
We decided to highlight camera nonlinearity, quantization distortion, and read noise variability among camera nonidealities because of their generalizability across cameras and impact on SCOS measurement accuracy.There are other less generalizable nonidealities that a user might encounter when testing different cameras.For example, with the BAa camera, we observed that at certain camera settings (i.e., > 16 dB analog gain value), it produced intermittent intensity jumps of 1-2 DN in magnitude that were independent of any changes in illumination (See supplementary Fig. S3).Since K 2 is a function of intensity, these intensity jumps would introduce random step-like biases in K 2 and distort the resulting BFi waveforms.We observed the same behavior across multiple BAa cameras, though not all of the ones we had access to.Our solution was to avoid the range of analog gain values (16-24 dB) where this instability occurred.As another example, we observed that the BAd camera in its available 12-bit depth mode skipped every 9 th DN value, which appeared as empty bins in an intensity histogram of the raw images.The skipped counts would distort the calculated K 2 at the intensities correspond- ing to the skipped counts, and thus we disregarded the BAd camera's 12-bit mode and used its 8-bit mode which doesn't exhibit this behavior.In general, any nonideality that can impact either I (e.g., first-order nonlinearity, dark offset instability, skipped counts) or σ (I) (e.g., second-order nonlinearity, read noise instability) needs to be considered.
While we identified the BAa as the preferred camera for our SCOS system among the three cameras evaluated in this work, we note that the BAa camera may not necessarily be the optimal camera for other SCOS systems, since the overall performance of a SCOS system depends on the interplay between the camera and other system components such as the laser and the optics, such as choice of wavelength and fiber diameter, and because we have only evaluated a small sample of cameras among the pool of commercially available options.In addition, for our SNR simulations we assumed a fixed average photon flux per speckle of 22,619 s -1 equal to the value obtained during our mental subtraction experiment in Fig. 7.The photon flux per speckle can vary with the choice of source-detector separation, brain region measured, and subjects.We invite the user to utilize our recently developed noise model 25 , which was extended in this work to include the effects of the pixel-count-limited regime (Fig. 5) and pulsed illumination (Fig. 6), to predict the performance for a specific set of SCOS system parameters and experimental parameters.In conclusion, the camera characterization and parameter optimization procedure presented in this work serves as a guide for evaluating, optimizing, and comparing any set of cameras that a user wishes to consider for their SCOS system.

Figure 2 .
Figure 2. Dark offset and read noise variance distributions for the three cameras.(a) Normalized mean dark offset I dark distributions across pixels for the three cameras in units of DN.Here N is the number of pixels at a particular dark offset, and it is normalized by its maximum value N max .The mean dark offsets of the cameras are HA = 100.5DN, BAa = 49.4DN, and BAd = 9.7 DN.(b) Normalized read noise variance σ 2 r distributions across pixels for the three cameras in units of DN 2 .The RMS read noise values of the cameras are HA = 5.99 DN, BAa = 1.16 DN, and BAd = 0.48 DN.(c) Normalized read noise variance σ 2 r distributions for the three cameras in units of e −2 .The RMS read noise values of the cameras are HA = 1.28 e − , BAa = 1.97 e − , and BAd = 10.33 e − .

Figure 3 .
Figure 3. Impact of quantization distortion on SCOS measurement accuracy.(a) Maximum quantizationdistortion-induced error in measured mean intensity I as a function of the true variance σ 2 true .(b) Maximum quantization-distortion-induced error in measured variance σ 2 as a function of the true variance σ 2 true .The error in σ 2 asymptotically approaches 1/12 (red dashed line) with increasing σ 2 true .(c) Corresponding error in K 2 given the errors in I (a) and σ 2 (b) as a function of σ 2 true , after subtracting an assumed quantization-induced bias of 1/12 from the signal's variance.

Figure 4 .
Figure 4. Dark offset and read noise variability of the BAa camera.(a) Time course of pixel-averaged mean dark offset I dark and read noise variance σ 2 r .Dark measurements were performed every 10 min, and prior to the first measurement the camera was powered on but not acquiring images.Error bars represent the temporal standard deviation of the mean of each image (top) and the variance of each difference image (bottom).(b) Change in the I dark distribution across pixels between the two time points indicated.(c) Change in the σ 2 r

Figure 5 .
Figure 5. SCOS SNR dependence on exposure time and s/p ratio for the BAa camera.(a) SNR versus T exp for s/p = 0.84.(b) SNR versus s/p at T exp = 8.3 ms for speckle-count-limited and pixel-count-limited cases.When the SCOS system is speckle-count-limited, the total number of speckles/fiber modes is fixed at M = 3.3 × 10 6 , estimated from the area of the fiber output image and the s/p ratio obtained experimentally.In the specklecount-limited case we assume that the camera has enough pixels to image all the speckles.When the system is pixel-count-limited, the total number of pixels is fixed at 1936 × 1216 pixels for the BAa camera, and we assume all pixels are filled with speckles.The SNR vs. s/p of our fiber-based SCOS system follows the solid red and blue lines.BAa camera parameter values of 1.97 e − RMS read noise, 16% quantum efficiency (QE) at 852 nm wavelength, 120 Hz maximum frame rate ( f max ) at 10-bit depth, and 1936 × 1216 pixels were used.An average photon flux per speckle of 22,619 s -1 (as derived in the Methods) and a measurement rate of 10 Hz were used. https://doi.org/10.1038/s41598-024-62106-ywww.nature.com/scientificreports/

Figure 6 .
Figure 6.Impact of varying the laser pulsing factor on SCOS SNR with the BAa camera.(a-b) SNR as a function of s/p and T exp at (a) PF = 1 and (b) PF = 10 for the speckle-count-limited case.The total number of speckles/fiber modes is fixed at M = 3.3 × 10 6 as done in Fig. 5, and we assume the camera has enough pixels to image all the speckles.(d-e) SNR as a function of s/p and T exp at (d) PF = 1 and (e) PF = 10 for the pixel-count- limited case.The total number of pixels is fixed at 1936 × 1216 pixels, and we assume all pixels are filled with speckles.The optimal SNR and corresponding K 2 terms are plotted as a function of laser PF for both the (c) speckle-count-limited case and (f) pixel-count-limited case.In both cases, the SNR plateaus as the blood-flowinduced speckle contrast K 2 f dominates and the fundamental noise σ K 2 f becomes the dominant noise source.BAa camera parameter values of 1.97 e − RMS read noise, 16% quantum efficiency (QE) at 852 nm wavelength, 120 Hz maximum frame rate ( f max ) at 10 bit depth, and 1936 × 1216 pixels were used.An average photon flux per speckle of 22,619 s -1 (as derived in the Methods) and a measurement rate of 10 Hz were used.

Figure 7 .
Figure 7. Cardiac and mental subtraction measurements using the BAa camera with optimal operating parameters.(a) Diagram of the SCOS measurement setup.Brain and skull image is obtained from Wikimedia Commons.All the other elements of the image are generated by the authors using Microsoft PowerPoint.(b-c) Recovery of the pulsatile waveform in (b) mean intensity I and (c) BFi = 1/K 2 f using SCOS.The three peaks (P1, P2, P3) and dicrotic notch are clearly visible and labeled in the BFi waveform.(d-e) Significant brain activation and recovery to baseline can be seen in both the (d) �OD = log 10 (I 0 /I(t)) (p = 2.04 × 10 -7 ) and (e) relative change in BFi (p = 1.06 × 10 -5 ).Shown are the average OD and BFi waveforms from fifteen trials.The green rectangular shaded region represents the time duration of a trial.The red shaded error region represents the standard error across the 15 trials.